//
// Created by HP on 2024/1/8.
//

#ifndef AURORA_ST_AURORA_UI_H
#define AURORA_ST_AURORA_UI_H

#include "common_inc.h"
#include "lcd_driver.h"
#include "encoderkey_driver.h"

#include "aurora_label.h"

#include "aurora_menu.h"
#include "aurora_mode.h"
#include "aurora_wave.h"
#include "aurora_info.h"


#include "aurora_img.h"
#define UI_ENABLE 0x5a
#define UI_DISENABLE 0xff
class Aurora_UI{


    typedef enum PAGE_NAME{

        menu_page = 0, //root 页面
        mode_page = 1,      //用来选择电机运行模式
        wave_page = 2,      //用来显示电机波形
        detail_page = 3,    //用来显示电机的详细信息
        standby_page = 4,   //休眠页面，用来显示图片
        //其它页面
        file_page = 5,   //文件更新页面
    }PAGE_NAME;
public:
    Aurora_UI();
public:
    void addEncoderKey_Driver(EncoderKey_Driver *encoderkey_s);
    void add_Driver(LCD_Driver *lcd_s,Aurora_Font *font_s);
    void addLCD_Driver(LCD_Driver *lcd_s);
    void addFont_Driver(Aurora_Font *font_s);
public:
    void dealKeyEvent();
    void dealKeyEventIN_menu(EncoderKeyState encoderKeyState);
    void dealKeyEventIN_mode(EncoderKeyState encoderKeyState);
    void dealKeyEventIN_wave(EncoderKeyState encoderKeyState);
    void dealKeyEventIN_detail(EncoderKeyState encoderKeyState);
    void dealKeyEventIN_img(EncoderKeyState encoderKeyState);


    void dealmsgEvent_from_FOC(struct Aurora_FOC2UI_MSG *comm2ui_msg_p);
    void dealmsgEvent_from_COMM(struct Aurora_COMM2UI_MSG *comm2ui_msg_p);


    void load_ui_parameter();
    void boot_animation();


    void send_halt_motor();
    void send_recovery_motor();
private:
    void switch_to_menu();

private:
    LCD_Driver *lcd;
    Aurora_Font *font;
    EncoderKey_Driver *encoderkey; // 按键输入
private:
    Aurora_Menu   *menu;

    Aurora_Mode   *mode;
    Aurora_Wave   *wave;
    Aurora_Info   *detail;
    Aurora_Img    *img;
private:
    PAGE_NAME curr_page;

    uint8_t select_motor;
    uint8_t mode_sel;

public:
    UI_PARAMETER_STORAGE ui_param;
};


#endif //AURORA_ST_AURORA_UI_H
